package org.wisdom.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.wisdom.interceptor.WisdomFeignInterceptor;

import feign.RequestInterceptor;

/**
 * feign拦截器配置类
 *
 * @author zhangzhiyan
 * @date 2021/07/21 13:54
 **/
public class WisdomFeignInterceptorConfiguration {

    @Value("${wisdom.feign.secretKey:S32^&sdfSdx231*23f!3#xWe}")
    private String wisdomFeignSecretKey;

    @Value("${wisdom.security.jwt.tokenSchema:Bearer }")
    private String tokenSchema;

    /**
     * 添加拦截器
     *
     * @return feign.RequestInterceptor
     * @author zhangzhiyan
     * @date 2021/07/21 15:20
     */
    @Bean("wisdomFeignInterceptor")
    public RequestInterceptor getRequestInterceptor() {
        return new WisdomFeignInterceptor(tokenSchema, wisdomFeignSecretKey);
    }

}
